var success_ele = document.querySelector(".success_ele")
var error_ele = document.querySelector(".error_ele")
var ipt_user = document.querySelector("#nc");
var ipt_pass = document.querySelector("#pwd");
document.querySelector(".over").onclick = function () {
    var user_value = ipt_user.value;
    var pass_value = ipt_pass.value;
    var url = "http://localhost/360mall/lore/register.php";
    url += "?username=" + user_value + "&password=" + pass_value;

    ajax(url, {
        callback: function (res) {
            res = JSON.parse(res)
            if (res.type === "success") {
                success_ele.style.display = "block"
                setTimeout(function () {
                    success_ele.style.display = "none"
                    location.href = "../login.html"
                }, 2000);
                setCookie("username", user_value)
            }
            if (res.type === "error") {
                error_ele.style.display = "block"
                setTimeout(function () {
                    error_ele.style.display = "none"
                    location.reload()
                }, 2000);
            }
        }
    });
};